package domain;
// Generated 14-jul-2009 13:45:36 by Hibernate Tools 3.2.1.GA


import java.sql.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * Mobileconsumption generated by hbm2java
 */
@Entity
@Table(name="mobileconsumption"
    ,catalog="domeco"
)
public class Mobileconsumption  implements java.io.Serializable, Comparable<Mobileconsumption> {


     private Integer idMobileCons;
     private Invoice invoice;
     private Consumption consumption;
     private Date dateFrom;
     private Date dateTo;
     private String url;
     private Set<Messages> messageses = new HashSet<Messages>(0);
     private Set<Calls> callses = new HashSet<Calls>(0);

    public Mobileconsumption() {
    }

	
    public Mobileconsumption(Invoice invoice, Consumption consumption, Date dateFrom, Date dateTo, String url) {
        this.invoice = invoice;
        this.consumption = consumption;
        this.dateFrom = dateFrom;
        this.dateTo = dateTo;
        this.url = url;
    }
    public Mobileconsumption(Invoice invoice, Consumption consumption, Date dateFrom, Date dateTo, String url, Set<Messages> messageses, Set<Calls> callses) {
       this.invoice = invoice;
       this.consumption = consumption;
       this.dateFrom = dateFrom;
       this.dateTo = dateTo;
       this.url = url;
       this.messageses = messageses;
       this.callses = callses;
    }
   
     @Id @GeneratedValue(strategy=IDENTITY)
    
    @Column(name="idMobileCons", unique=true, nullable=false)
    public Integer getIdMobileCons() {
        return this.idMobileCons;
    }
    
    public void setIdMobileCons(Integer idMobileCons) {
        this.idMobileCons = idMobileCons;
    }
@ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="invoiceFK", nullable=false)
    public Invoice getInvoice() {
        return this.invoice;
    }
    
    public void setInvoice(Invoice invoice) {
        this.invoice = invoice;
    }
@ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="consFK", nullable=false)
    public Consumption getConsumption() {
        return this.consumption;
    }
    
    public void setConsumption(Consumption consumption) {
        this.consumption = consumption;
    }
    @Temporal(TemporalType.DATE)
    @Column(name="dateFrom", nullable=false, length=10)
    public Date getDateFrom() {
        return this.dateFrom;
    }
    
    public void setDateFrom(Date dateFrom) {
        this.dateFrom = dateFrom;
    }
    @Temporal(TemporalType.DATE)
    @Column(name="dateTo", nullable=false, length=10)
    public Date getDateTo() {
        return this.dateTo;
    }
    
    public void setDateTo(Date dateTo) {
        this.dateTo = dateTo;
    }
    
    @Column(name="url", nullable=false, length=250)
    public String getUrl() {
        return this.url;
    }
    
    public void setUrl(String url) {
        this.url = url;
    }
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="mobileconsumption")
    public Set<Messages> getMessageses() {
        return this.messageses;
    }
    
    public void setMessageses(Set<Messages> messageses) {
        this.messageses = messageses;
    }
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="mobileconsumption")
    public Set<Calls> getCallses() {
        return this.callses;
    }
    
    public void setCallses(Set<Calls> callses) {
        this.callses = callses;
    }

    public int compareTo(Mobileconsumption m){
        int res = 0;
        if (this.getDateFrom().compareTo(m.getDateFrom())<0){
            res = -1;
        } else if (this.getDateFrom().compareTo(m.getDateFrom())>0){
            res = 1;
        }
        return res;
    }

}


